package com.yanqu.road.server.cmd.activity.douluodalu;

import com.yanqu.road.entity.enums.eGamePlayerEventType;
import com.yanqu.road.pb.activity.douluodalu.DouLuoDaLuProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.activity.douluodalu.DouLuoDaLuModule;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.S_DOU_LUO_DA_LU_SYNC_USER_DATA_TO_SERVER,desc = "跨服下发玩家数据给区服")
public class DouLuoDaLuSyncUserDataCmdFromCross extends AbstractCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {

        DouLuoDaLuProto.DouLuoDaLuSyncUserDataToServerMsg reqMsg = DouLuoDaLuProto.DouLuoDaLuSyncUserDataToServerMsg.parseFrom(packet.getBytes());

        DouLuoDaLuModule module = player.getModule(DouLuoDaLuModule.class);
        module.regionId = reqMsg.getRegionId();
        module.teamId = reqMsg.getTeamId();
        if(reqMsg.hasScore1()){
            module.updateConditionValue(reqMsg.getScore1(), eGamePlayerEventType.DouLuoDaLuPhaseOneUserScoreCrossRank.getValue());
        }
        if(reqMsg.hasScore2()){
            module.updateConditionValue(reqMsg.getScore2(), eGamePlayerEventType.DouLuoDaLuPhaseTwoUserScoreCrossRank.getValue());
        }
    }

    @Override
    public void sendData(GamePlayer player) {

    }
}
